import path from 'path';
import fs from 'fs-extra';
import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';

function copyFile() {
	return {
		enforce: 'post',
		async writeBundle() {
			await fs.copy(
				path.resolve(__dirname, 'static'),
				path.join(
					__dirname,
					'unpackage/dist',
					process.env.NODE_ENV === 'production' ? 'build' : 'dev',
					process.env.UNI_PLATFORM,
					'static'
				)
			);
		},
	};
}

export default defineConfig({
	base: '/phone/', 
	plugins: [uni()],
	// plugins: [uni(), copyFile()],
	// build: {
	// 	minify: 'terser',
	// 	terserOptions: {
	// 		compress: {
	// 			drop_console: true,
	// 		},
	// 	},
	// },
	// css: {
	//     preprocessorOptions: {
	//       scss: {
	//         javascriptEnabled: true,
	//         additionalData: `@import "@/theme/cartoon.scss";`
	//       }
	//     }
	// }
});
